class WorkItemTypeStagesController < ApplicationController

  def index
    @stage = Stage.find(params[:id])
  end
  
  def new
    @stage = Stage.find(params[:stage_id])
  end

  def create
    @stage = Stage.find(params[:stage_id])
    @work_item_type = WorkItemType.find(params[:work_item_type_id])
    @stage.work_item_types << @work_item_type
    render :new unless @stage.save
  end

  def destroy
    @stage = Stage.find(params[:stage_id])
    @work_item_type = WorkItemType.find(params[:work_item_type_id])
    @stage.work_item_types.delete(@work_item_type) if DesignerWorkItem.find_all_by_stage_id_and_work_item_type_id(@stage.id,@work_item_type.id).empty? and WorkItem.find_all_by_stage_id_and_work_item_type_id(@stage.id,@work_item_type.id).empty?
  end

end
